package com.mall.hadoop.job.singletopicday;
import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * avg(time)单题按天统计
 * @author liugb
 * date 2016 7 12
 */
public class SingletopicdayMap extends Mapper<LongWritable, Text, Text, IntWritable>{
	public static Logger logger = LoggerFactory.getLogger(SingletopicdayMap.class);
	@Override
	protected void map(LongWritable key, Text value, Context context)throws IOException, InterruptedException {
		// TODO Auto-generated method stub
		try {
			String str = value.toString();
			String[] split = str.split(",");
			int t_id = Integer.parseInt(split[0]);                   //题目id
			int t_time = Integer.parseInt(split[1]);                 //测试时间
			context.write(new Text(String.valueOf(t_id)),new IntWritable(t_time));	
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
	}

}
